<template>
  <section v-if="hasPermission">
    <slot></slot>
  </section>
</template>

<script>
  export default {
    name: "Permission",
    data() {
      return {
        hasPermission: true
      }
    },
    props: {
      url: {
        type: String,
        required: true
      }
    },
    methods: {
      permissionCheck() {
        this.$store.dispatch("permissionCheck", {url: this.url}).then(hasPermission => {
          this.hasPermission = hasPermission;
        }).catch(err=> {
          console.log(err);
        })
      }
    },
    created() {
      this.permissionCheck();
    }
  }
</script>

<style scoped>

</style>
